/**
 * @fileOverview 数据字典
 * @author goodzsq@gmail.com
 */

module.exports = {
    serialize: function(v) {
        return String(v);
    },
    parse: function(v) {
        return String(v);
    },
    load: function(v) {
        var obj;
        if (typeof v === 'string') {
            try {
                eval('obj = ' + v);
            } catch (e) {
                return null;
            }
            return obj;
        } else {
            return null;
        }
    },
    save: function(v) {
        var type = typeof v;
        if (type === 'object') {
            _.each(v, function(value, key){
                v[key] = String(v);
            });
            return JSON.stringify(v);
        } else if(type === 'string') {
            return v;
        } else{
            return '';
        }
    }
};
